package com.oocl.hw1.task1;

import com.oocl.hw1.task1.pojo.AnalyzeRes;
import com.oocl.hw1.task1.utils.RegularExpressionUtil;
import com.oocl.hw1.task1.utils.RegularExpressionUtil.Regular;

public class TextAnalyzer {

	private AnalyzeRes analyzeRes;
	
	public TextAnalyzer(){
		this.analyzeRes = new AnalyzeRes();
	}
	
	public void analyzeText(String text){
		if(text == null || text.length() ==0) return;
		this.analyzeRes.countNumber += RegularExpressionUtil.statistics(Regular.NUMBER, text);
		this.analyzeRes.countAlphabat +=  RegularExpressionUtil.statistics(Regular.ALPHABET, text);
		this.analyzeRes.countEnglishPunctuation +=  RegularExpressionUtil.statistics(Regular.ENGLISH_PUNCTUATION, text);
		this.analyzeRes.countChinesePunctuation +=  RegularExpressionUtil.statistics(Regular.CHINESE_PUNCTUATION, text);
		this.analyzeRes.countChineseCharacter +=  RegularExpressionUtil.statistics(Regular.CHINESE_CHARACTER, text);
	}

	public AnalyzeRes getAnalyzeRes() {
		return analyzeRes;
	}

	public void setAnalyzeRes(AnalyzeRes analyzeRes) {
		this.analyzeRes = analyzeRes;
	}
	
	public String showRes(){
		return this.analyzeRes.toString();
	}
}
